package com.iris.egrant.webapp.app.struts2.proposal;


import com.iris.egrant.service.ServiceConstants;
import com.iris.egrant.model.formInit.FormBaseLibrary;
import com.iris.egrant.model.proposal.Proposal;
import com.iris.egrant.model.proposal.ProposalCachedExtend;
import com.iris.egrant.remote.http.service.ServiceFactory;
import com.iris.egrant.app.service.proposal.ProposalLocalService;
import com.iris.egrant.service.proposal.ProposalService;
import com.iris.egrant.service.ServiceUtils;
import com.iris.egrant.web.struts2.Struts2Utils;
import com.iris.egrant.utils.date.DateFormator;
import com.iris.egrant.utils.date.DateUtils;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.math.NumberUtils;

import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;


public class ViewLocalAction extends ActionSupport {
    private static final long serialVersionUID = 7812080722096840624L;
    private Long posCode;
    private Long grantCode;
    private Long subGrantCode;
    private String subGrantNo;
    private Long helpGrantCode;
    private String viewLocation;
    private Long formCode;
    private String statYear;
    private String pdfStatus;
    private String xmlData;
    private ProposalCachedExtend pcx;
    private Long prjCode;
    @Resource(name = "serviceFactory")
    private ServiceFactory serviceFactory;


    public String viewProposal() throws Exception {
        /* 110 */
        String prpCodeStr = Struts2Utils.getParameter("prpCodeStr");
        /* 111 */
        String posCodeStr = Struts2Utils.getParameter("posCodeStr");
        /* 112 */
        String grantCodeStr = Struts2Utils.getParameter("grantCodeStr");
        /* 113 */
        String subGrantCodeStr = Struts2Utils.getParameter("subGrantCodeStr");
        /* 114 */
        String atvtype = Struts2Utils.getParameter("atvtype");
        /* 115 */
        String keyCode = Struts2Utils.getParameter("keyCode");
        /* 116 */
        String ltype = Struts2Utils.getParameter("ltype");
        /* 117 */
        Struts2Utils.getRequest().setAttribute("ltype", ltype);

        /* 119 */
        Struts2Utils.getRequest().setAttribute("isJoint", Struts2Utils.getParameter("isJoint"));

        /* 121 */
        if (!StringUtils.isNotBlank(prpCodeStr)) {
            /* 122 */
            return viewProposalByPrpcode(prpCodeStr, grantCodeStr, subGrantCodeStr);
        }

        try {
            /* 126 */
//            posCodeStr = ServiceUtils.decodeFromDes3(posCodeStr, "111111222222333333444444");
//            /* 127 */
//            if (grantCodeStr != null) {
//                /* 128 */
//                grantCodeStr = ServiceUtils.decodeFromDes3(grantCodeStr, "111111222222333333444444");
//            }
//            /* 130 */
//            if (subGrantCodeStr != null) {
//                /* 131 */
//                subGrantCodeStr = ServiceUtils.decodeFromDes3(subGrantCodeStr, "111111222222333333444444");
//            }
            /* 133 */
//            String[] posCodeStrs = posCodeStr.split("\\|");
//            /* 134 */
//            String[] grantCodeStrs = grantCodeStr.split("\\|");
            /* 135 */
//            if (grantCodeStrs.length > 0 && !grantCodeStrs[0].equals("")) {
//
//                try {
//                    /* 138 */
//                    Long.parseLong(grantCodeStrs[0]);
//                    /* 139 */
//                } catch (Exception e) {
//                    /* 140 */
//                    grantCodeStr = ServiceUtils.decodeFromDes3(grantCodeStr, "111111222222333333444444");
//                    /* 141 */
//                    grantCodeStrs = grantCodeStr.split("\\|");
//                }
//            }

            /* 145 */
//            String[] subGrantCodeStrs = subGrantCodeStr.split("\\|");
//            /* 146 */
//            if (!"".equals(subGrantCodeStrs[0])) {
//                try {
//                    /* 148 */
//                    Long.parseLong(subGrantCodeStrs[0]);
//                    /* 149 */
//                } catch (Exception e) {
//                    /* 150 */
//                    subGrantCodeStr = ServiceUtils.decodeFromDes3(subGrantCodeStr, "111111222222333333444444");
//                    /* 151 */
//                    subGrantCodeStrs = subGrantCodeStr.split("\\|");
//                }
//            }
            /* 154 */
//            if (posCodeStrs.length != 2) {
//                /* 155 */
//                return "error";
//            }
            /* 157 */
//            Date timeParam = DateUtils.toDate(posCodeStrs[1], DateFormator.YEAR_MONTH_DAY_HH_MM_SS);
            /* 158 */
//            if (NumberUtils.isDigits(posCodeStrs[0]) && DateUtils.diffMillis(new Date(), timeParam) < ServiceConstants.VALIDATE_TIME.longValue()) {
                /* 159 */
//                if (!StringUtils.isEmpty(posCodeStrs[0]) && !StringUtils.isBlank(posCodeStrs[0])) {
//                    /* 160 */
                    this.posCode = Long.valueOf(posCodeStr);
//                }
                /* 162 */
//                if (grantCodeStrs != null && grantCodeStrs.length >= 1 && !StringUtils.isEmpty(grantCodeStrs[0]) && !StringUtils.isBlank(grantCodeStrs[0])) {
                    /* 163 */
                    this.grantCode = Long.valueOf(Long.parseLong(grantCodeStr));
//                }
                /* 165 */
//                if (subGrantCodeStrs != null && subGrantCodeStrs.length >= 1 && !StringUtils.isEmpty(subGrantCodeStrs[0]) && !StringUtils.isBlank(subGrantCodeStrs[0])) {
                    /* 166 */
                    this.subGrantCode = Long.valueOf(Long.parseLong(subGrantCodeStr));
//                }
//            } else {
//
//                /* 170 */
//                return "error";
//            }

            /* 173 */
        } catch (Exception e) {
            /* 174 */
            e.printStackTrace();
            /* 175 */
            return "error";
        }
        /* 177 */
        Map<String, Object> params = new HashMap<String, Object>();
        /* 178 */
        params.put("grant_code", this.grantCode);

        /* 180 */
        if (this.subGrantCode == null) {
            /* 181 */
            params.put("sub_grant_no", this.subGrantNo);
        } else {
            /* 183 */
            params.put("sub_grant_code", this.subGrantCode);
        }

        /* 186 */
        params.put("help_grant_code", this.helpGrantCode);
        /* 187 */
        params.put("prj_code", this.prjCode);
        /* 188 */
        params.put("atvtype", atvtype);
        /* 189 */
        params.put("keyCode", keyCode);
        /* 190 */
        Map<String, Object> resultMap = ((ProposalLocalService) this.serviceFactory.getService(ProposalLocalService.class)).viewPrp(params, this.posCode);
        /* 191 */
        if (resultMap == null) {
            /* 192 */
            return "error";
        }

        /* 195 */
        FormBaseLibrary fbl = (FormBaseLibrary) resultMap.get("fbl");


        /* 198 */
        this.formCode = fbl.getFormCode();
        /* 199 */
        this.viewLocation = fbl.getViewIndexUrl();
        /* 200 */
        Struts2Utils.getRequest().setAttribute("fbl", fbl);
        /* 201 */
        this.xmlData = ObjectUtils.toString(resultMap.get("xmlData"));
        /* 202 */
        this.statYear = ObjectUtils.toString(resultMap.get("statYear"));
        /* 203 */
        this.pdfStatus = ObjectUtils.toString(resultMap.get("pdfStatus"));
        /* 204 */
        return "view";
    }

    private String viewProposalByPrpcode(String prpCodeStr, String grantCodeStr, String subGrantCodeStr) throws Exception {
        /* 208 */
        String atvtype = Struts2Utils.getParameter("atvtype");
        /* 209 */
        String keyCode = Struts2Utils.getParameter("keyCode");
        /* 210 */
        Long prpCode = null;
        /*     */
        try {
            /* 212 */
            prpCodeStr = ServiceUtils.decodeFromDes3(prpCodeStr, "111111222222333333444444");
            /* 213 */
            if (grantCodeStr != null) {
                /* 214 */
                grantCodeStr = ServiceUtils.decodeFromDes3(grantCodeStr, "111111222222333333444444");
                /*     */
            }
            /* 216 */
            if (subGrantCodeStr != null) {
                /* 217 */
                subGrantCodeStr = ServiceUtils.decodeFromDes3(subGrantCodeStr, "111111222222333333444444");
                /*     */
            }
            /* 219 */
            String[] prpCodeStrs = prpCodeStr.split("\\|");
            /* 220 */
            String[] grantCodeStrs = grantCodeStr.split("\\|");
            /* 221 */
            String[] subGrantCodeStrs = subGrantCodeStr.split("\\|");
            /* 222 */
            if (prpCodeStrs.length != 2) {
                /* 223 */
                return "error";
                /*     */
            }
            /* 225 */
            Date timeParam = DateUtils.toDate(prpCodeStrs[1], DateFormator.YEAR_MONTH_DAY_HH_MM_SS);
            /* 226 */
            if (NumberUtils.isDigits(prpCodeStrs[0]) && DateUtils.diffMillis(new Date(), timeParam) < ServiceConstants.VALIDATE_TIME.longValue()) {
                /* 227 */
                if (!StringUtils.isEmpty(prpCodeStrs[0]) && !StringUtils.isBlank(prpCodeStrs[0])) {
                    /* 228 */
                    prpCode = Long.valueOf(Long.parseLong(prpCodeStrs[0]));
                    /*     */
                }
                /* 230 */
                if (grantCodeStrs != null && grantCodeStrs.length >= 1 && !StringUtils.isEmpty(grantCodeStrs[0]) && !StringUtils.isBlank(grantCodeStrs[0])) {
                    /* 231 */
                    this.grantCode = Long.valueOf(Long.parseLong(grantCodeStrs[0]));
                    /*     */
                }
                /* 233 */
                if (subGrantCodeStrs != null && subGrantCodeStrs.length >= 1 && !StringUtils.isEmpty(subGrantCodeStrs[0]) && !StringUtils.isBlank(subGrantCodeStrs[0])) {
                    /* 234 */
                    this.subGrantCode = Long.valueOf(Long.parseLong(subGrantCodeStrs[0]));
                    /*     */
                }
                /*     */
            } else {
                /*     */
                /* 238 */
                return "error";
                /*     */
            }
            /*     */
            /* 241 */
        } catch (Exception e) {
            /* 242 */
            e.printStackTrace();
            /* 243 */
            return "error";
            /*     */
        }
        /* 245 */
        Map<String, Object> params = new HashMap<String, Object>();
        /* 246 */
        params.put("grant_code", this.grantCode);
        /*     */
        /* 248 */
        if (this.subGrantCode == null) {
            /* 249 */
            params.put("sub_grant_no", this.subGrantNo);
            /*     */
        } else {
            /* 251 */
            params.put("sub_grant_code", this.subGrantCode);
            /*     */
        }
        /*     */
        /* 254 */
        params.put("help_grant_code", this.helpGrantCode);
        /* 255 */
        params.put("prj_code", this.prjCode);
        /* 256 */
        params.put("atvtype", atvtype);
        /* 257 */
        params.put("keyCode", keyCode);
        /*     */
        /* 259 */
        if (prpCode == null) {
            /* 260 */
            return "error";
            /*     */
        }
        /* 262 */
        Proposal proposal = ((ProposalService) this.serviceFactory.getService(ProposalService.class)).getProposalByCode(prpCode);
        /* 263 */
        if (proposal != null) {
            /* 264 */
            Struts2Utils.getRequest().setAttribute("prpName", proposal.getZhTitle());
            /* 265 */
            Struts2Utils.getRequest().setAttribute("posCode", proposal.getPosCode());
            /*     */
        } else {
            /* 267 */
            Struts2Utils.getRequest().setAttribute("prpName", "");
            /*     */
        }
        /*     */
        /* 270 */
        FormBaseLibrary fbl = ((ProposalService) this.serviceFactory.getService(ProposalService.class)).viewPrpByPrpCode(params, prpCode);
        /*     */
        /* 272 */
        if (fbl == null) {
            /* 273 */
            return "error";
            /*     */
        }
        /*     */
        /* 276 */
        String[] productxmlarr = ((ProposalService) this.serviceFactory.getService(ProposalService.class)).getproductxml(fbl.getXmlData());
        /* 277 */
        String productxml = productxmlarr[0];
        /* 278 */
        Struts2Utils.getRequest().setAttribute("zh_products", productxml);
        /* 279 */
        productxml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><data><zh_products>" + productxml + "</zh_products></data>";
        /*     */
        /*     */
        /* 282 */
        setFormCode(fbl.getFormCode());
        /*     */
        /* 284 */
        setViewLocation(fbl.getViewIndexUrl());
        /* 285 */
        setXmlData(fbl.getXmlData());
//    /* 286 */     if (SecurityUtils.getCurrentUserRoleId() != ExpConstants.EXP_ROLE_PYR.longValue()) {
        /* 287 */
        Struts2Utils.getRequest().setAttribute("fbl", fbl);
//      /*     */     }
        /*     */
        /*     */
        /* 291 */
        return "view";
        /*     */
    }
    /*     */


    public Long getPosCode() {
        /* 377 */
        return this.posCode;
    }

    public void setPosCode(Long posCode) {
        /* 381 */
        this.posCode = posCode;
    }

    public Long getGrantCode() {
        /* 385 */
        return this.grantCode;
    }

    public void setGrantCode(Long grantCode) {
        /* 389 */
        this.grantCode = grantCode;
    }

    public Long getSubGrantCode() {
        /* 393 */
        return this.subGrantCode;
    }

    public void setSubGrantCode(Long subGrantCode) {
        /* 397 */
        this.subGrantCode = subGrantCode;
    }

    public String getSubGrantNo() {
        /* 401 */
        return this.subGrantNo;
    }

    public void setSubGrantNo(String subGrantNo) {
        /* 405 */
        this.subGrantNo = subGrantNo;
    }

    public Long getHelpGrantCode() {
        /* 409 */
        return this.helpGrantCode;
    }

    public void setHelpGrantCode(Long helpGrantCode) {
        /* 413 */
        this.helpGrantCode = helpGrantCode;
    }

    public String getViewLocation() {
        /* 417 */
        return this.viewLocation;
    }

    public void setViewLocation(String viewLocation) {
        /* 421 */
        this.viewLocation = viewLocation;
    }

    public Long getFormCode() {
        /* 425 */
        return this.formCode;
    }

    public void setFormCode(Long formCode) {
        /* 429 */
        this.formCode = formCode;
    }

    public String getXmlData() {
        /* 433 */
        return this.xmlData;
    }

    public void setXmlData(String xmlData) {
        /* 437 */
        this.xmlData = xmlData;
    }

    public ProposalCachedExtend getPcx() {
        /* 441 */
        return this.pcx;
    }

    public void setPcx(ProposalCachedExtend pcx) {
        /* 445 */
        this.pcx = pcx;
    }

    public Long getPrjCode() {
        /* 449 */
        return this.prjCode;
    }

    public void setPrjCode(Long prjCode) {
        /* 453 */
        this.prjCode = prjCode;
    }

    public ServiceFactory getServiceFactory() {
        /* 457 */
        return this.serviceFactory;
    }

    public void setServiceFactory(ServiceFactory serviceFactory) {
        /* 461 */
        this.serviceFactory = serviceFactory;
    }

    public static long getSerialversionuid() {
        /* 465 */
        return 7812080722096840624L;
    }

    public String getStatYear() {
        /* 469 */
        return this.statYear;
    }

    public void setStatYear(String statYear) {
        /* 473 */
        this.statYear = statYear;
    }

    public String getPdfStatus() {
        /* 477 */
        return this.pdfStatus;
    }

    public void setPdfStatus(String pdfStatus) {
        /* 481 */
        this.pdfStatus = pdfStatus;
    }
}


/* Location:              D:\文件\123\WEB-INF\classes\!\com\iris\egrant\webapp\app\struts2\proposal\ViewLocalAction.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       1.1.3
 */